<template>
	<view>
		<home v-if="PageCur=='home'"></home>
		<!-- <basics v-if="PageCur=='basics'"></basics>
		<components v-if="PageCur=='component'"></components>
		<plugin v-if="PageCur=='plugin'"></plugin>-->
		<about v-if="PageCur=='about'"></about>
		<!-- app不支持动态组件 -->
		<!-- <component :is="mapPage[PageCur]"></component> -->
		<view class="cu-bar tabbar bg-white shadow foot">
			<view class="action" @click="NavChange" data-cur="home">
				<view class='cuIcon-cu-image'>
					<image :src="'/static/tabbar/shouye' + [PageCur=='home'?'_cur':''] + '.png'"></image>
				</view>
				<view :class="PageCur=='home'?'text-blue':'text-gray'">首页</view>
			</view>
			<view class="action" @click="NavChange" data-cur="cart">
				<view class='cuIcon-cu-image'>
					<image :src="'/static/tabbar/cart' + [PageCur=='cart'?'_cur':''] + '.png'"></image>
				</view>
				<view :class="PageCur=='cart'?'text-blue':'text-gray'">库存</view>
			</view>
			<view class="action" @click="NavChange" data-cur="report">
				<view class='cuIcon-cu-image'>
					<image :src="'/static/tabbar/report' + [PageCur == 'report'?'_cur':''] + '.png'"></image>
				</view>
				<view :class="PageCur=='report'?'text-blue':'text-gray'">统计</view>
			</view>
			<view class="action" @click="NavChange" data-cur="about">
				<view class='cuIcon-cu-image'>
					<image :src="'/static/tabbar/user' + [PageCur == 'about'?'_cur':''] + '.png'"></image>
				</view>
				<view :class="PageCur=='about'?'text-blue':'text-gray'">我的</view>
			</view>
		</view>
		
		<view class="content">
			<mask v-if="showMask"></mask>
		</view>
	</view>
</template>

<script>
	import mask from '@/pages/component/mask.vue';
	import formatData from '@/common/formData.js';
	export default {		
		data() {
			return {
				PageCur: 'home',
				mapPage:{
					'home':'home',
					'cart':'cart',
					'report':'report',
					'about':'about',
				},
				vioQs:false,
				showMask:false,
			}
		},
		components: {mask},
		methods: {
			NavChange: function(e) {
				this.PageCur = e.currentTarget.dataset.cur
			},
		},
		onLoad(query) {	
			// console.log('onload index');
			var _this = this;
			if(query.page){
				this.PageCur = query.page;
			}
			
			if(!this.vioQs){
				// this.$vPrint.close();
				setTimeout(() =>{
					//#ifdef APP-PLUS
				    this.$vPrint.init();
					//#endif
					this.vioQs = true;
				},3000);
			}
			//获取权限信息
			// console.log('index onload call');
			// formatData.getUserinfo();
		},
		beforeMount(){
			
		},
		mounted(){
			
		},
		destroyed() {
			//#ifdef APP-PLUS
			if(this.vioQs){
				this.$vPrint.close();
			}
			//#endif
		},
		onBackPress() {			
			let self = this;
			if (this.showMask) {
				this.showMask = false;
				return true;
			} else {
				//#ifdef APP-PLUS
				uni.showModal({
					title: '提示',
					content: '是否退出？',
					success: function(res) {
						if (res.confirm) {
							self.$vPrint.close();
							plus.runtime.quit();// 退出当前应用，该方法只在App中生效
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					},
				});
				//#endif
				return true;
			}
		},
		onShareAppMessage(res) {
		    return {
		      title: '易奇样品间',
		      path: '/pages/index/index'
		    }
		}
	}
</script>

<style>

</style>
